package com.jrzh.mvc.search.sys;

import org.apache.commons.lang.StringUtils;

import com.jrzh.framework.base.search.BaseSearch;
import com.jrzh.framework.searchutils.Criteria;
import com.jrzh.framework.searchutils.Restrictions;

public class ConfigSearch extends BaseSearch{

	private static final long serialVersionUID = -4651421527375343014L;
	
	private String equalKey;
	private String likeKey;
	private Object[] notInKeys;

	public String getEqualKey() {
		return equalKey;
	}

	public void setEqualKey(String equalKey) {
		this.equalKey = equalKey;
	}

	public String getLikeKey() {
		return likeKey;
	}

	public void setLikeKey(String likeKey) {
		this.likeKey = likeKey;
	}

	public Object[] getNotInKeys() {
		return notInKeys;
	}

	public void setNotInKeys(Object[] notInKeys) {
		this.notInKeys = notInKeys;
	}

	@Override
	public void setCriterias(Criteria<?> criterias) {
		if(StringUtils.isNotBlank(equalKey)){
			criterias.add(Restrictions.eq("key", equalKey));
		}
		if(StringUtils.isNotBlank(likeKey)){
			criterias.add(Restrictions.like("key", likeKey+"%"));
		}
		if(null != notInKeys && notInKeys.length > 0){
			criterias.add(Restrictions.notIn("key", notInKeys));
		}
	}

}
